import 'dart:convert';

import 'package:amway_superapp_creator_plugin/utils/sp_util.dart';
import 'package:amway_superapp_creator_plugin/analysis/zhuge_identify.dart';
import 'package:zhugeio/zhugeio.dart';

enum CirclePageType {
  Page,
  circleDetails,
  circleEdite,
  circleCheckOffTag,
  circleAddAlbumVideo,
  leftDrawCard,
  delCircle,
  addCover,
  addGoods,
  circleSave,
  checkAutoApprobe,
  imageDetailsSave,
  delGoods,
  circleDetailsEditer,
  circleClickSend,
  circleRevokeSend,
  circleSendResultDialog,
}

class ZhugeCircleAnalysis {
  static String _circlePageType(CirclePageType circlePageType) {
    switch (circlePageType) {
      case CirclePageType.Page:
        return "SuperAPP_创玩小站我的圈子列表页";
        break;
      case CirclePageType.circleDetails:
        return "SuperAPP_创玩小站图文详情编辑动态页";
        break;
      case CirclePageType.circleEdite:
        return "SuperAPP_创玩小站编辑资料页";
        break;
      case CirclePageType.circleCheckOffTag:
        return "SuperAPP_创玩小站我的圈子列表页_勾选展示";
        break;
      case CirclePageType.circleAddAlbumVideo:
        return "SuperAPP_创玩小站我的圈子列表页_点击添加图文视频";
        break;
      case CirclePageType.leftDrawCard:
        return "SuperAPP_创玩小站我的圈子列表页_左划图文卡片";
        break;
      case CirclePageType.delCircle:
        return "SuperAPP_创玩小站我的圈子列表页_点击删除卡片";
        break;
      case CirclePageType.addCover:
        return "SuperAPP_创玩小站图文详情编辑动态页_点击添加封面";
        break;
      case CirclePageType.addGoods:
        return "SuperAPP_创玩小站图文详情编辑动态页_点击添加商品";
        break;
      case CirclePageType.circleSave:
        return "SuperAPP_创玩小站选择商品页_点击保存";
        break;
      case CirclePageType.checkAutoApprobe:
        return "SuperAPP_创玩小站图文详情编辑动态页_勾选保存自动审核";
        break;
      case CirclePageType.imageDetailsSave:
        return "SuperAPP_创玩小站图文详情编辑动态页_点击保存按钮";
        break;
      case CirclePageType.delGoods:
        return "SuperAPP_创玩小站图文详情编辑动态页_点击删除商品";
        break;
      case CirclePageType.circleDetailsEditer:
        return "SuperAPP_创玩小站我的圈子详情页_点击编辑";
        break;
      case CirclePageType.circleClickSend:
        return "SuperAPP_创玩小站我的圈子详情页_点击发布";
        break;
      case CirclePageType.circleRevokeSend:
        return "SuperAPP_创玩小站我的圈子详情页_点击撤销发布";
        break;
      case CirclePageType.circleSendResultDialog:
        return "SuperAPP_创玩小站我的圈子详情页_发布结果弹窗";
        break;
    }
  }

  ///圈子列表页面加载完成
  static circlePagLoadFinsh() {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType((CirclePageType.Page)), {
        "事件类型": "页面浏览",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无"
      });
    });
  }

  ///圈子详情页加载完成
  static circleDetailsPagLoadFinsh(int circleCoverState) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType((CirclePageType.circleDetails)), {
        "事件类型": "页面浏览",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "封面":circleCoverState==0?"空":circleCoverState==1?"审核未通过":"审核通过",//<空/审核未通过/审核通过>
      });
    });
  }

  ///圈子详情页加载完成
  static circleDetails(String id,String title) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType((CirclePageType.circleDetails)), {
        "事件类型": "页面浏览",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "文章ID":id,
        "文章标题":title,
      });
    });
  }


  ///页面选择
  static circlePageCheck( String pageName,
      {bool isSel}) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType(CirclePageType.circleCheckOffTag), {
        "事件类型": "点击事件",
        "事件详情": isSel ? "勾选" : "不勾选",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "行为对象": "选择项",
        "页面名称": pageName,
      });
    });
  }

  ///点击添加图文或视频
  static circleAddVideoAlbumPage(String title) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType(CirclePageType.circleAddAlbumVideo), {
        "事件类型": "点击事件",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "行为对象": "按钮",
        "页面名称": title,
      });
    });
  }

  ///卡片左滑
  static circleLeftDrawCard(String pageTitle,int sendState,String articleID,String articleTitle) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType(CirclePageType.leftDrawCard), {
        "事件类型": "点击事件",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "行为对象": "按钮",
        "页面名称": pageTitle,
        "发布状态":sendState==0?"已发布":sendState==1?"审核未通过":"待审核",//0 已发布
        "文章ID":articleID,
        "文章标题":articleTitle,
        "行为类型":"点击",
      });
    });
  }

  static circleDelCard(String pageTitle,int sendState,String articleID,String articleTitle) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType(CirclePageType.delCircle), {
        "事件类型": "点击事件",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "行为对象": "按钮",
        "页面名称": pageTitle,
        "发布状态":sendState==0?"已发布":sendState==1?"审核未通过":"待审核",//0 已发布
        "文章ID":articleID,
        "文章标题":articleTitle,
        "行为类型":"点击",
      });
    });
  }

  static circleAddCover(String pageTitle) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType(CirclePageType.delCircle), {
        "事件类型": "点击事件",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "行为对象": "按钮",
        "页面名称": pageTitle,
        "行为类型":"点击",
      });
    });
  }

  static circleAddGoods(String pageTitle) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType(CirclePageType.addGoods), {
        "事件类型": "点击事件",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "行为对象": "按钮",
        "页面名称": pageTitle,
        "行为类型":"点击",
      });
    });
  }

  static circleAddGoodsSave(String pageTitle,List<String>goodsId) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType(CirclePageType.addGoods), {
        "事件类型": "点击事件",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "行为对象": "按钮",
        "页面名称": pageTitle,
        "行为类型":"点击",
        "商品ID":goodsId!=null&&goodsId.length>0?json.encode(goodsId):null,
      });
    });
  }
  ///勾选自动审核
  static circleCheckAuto(String pageTitle,bool isSel) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType(CirclePageType.checkAutoApprobe), {
        "事件类型": "点击事件",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "事件详情":isSel?"选中":"不选中",
        "行为对象": "按钮",
        "页面名称": pageTitle,
        "行为类型":"点击",
      });
    });
  }
  ///点击保存圈子
  static circleSave(String pageTitle) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType(CirclePageType.circleSave), {
        "事件类型": "点击事件",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "行为对象": "按钮",
        "页面名称": pageTitle,
        "行为类型":"点击",
      });
    });
  }

  ///删除商品
  static circleDelGoods(String pageTitle) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType(CirclePageType.delGoods), {
        "事件类型": "点击事件",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "行为对象": "按钮",
        "页面名称": pageTitle,
        "行为类型":"点击",
      });
    });
  }

  ///圈子详情编辑
  static circleDetailsEditer(String pageTitle) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType(CirclePageType.circleDetailsEditer), {
        "事件类型": "点击事件",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "行为对象": "按钮",
        "页面名称": pageTitle,
        "行为类型":"点击",
      });
    });
  }

  ///圈子详情发布
  static circleDetailsSend(String pageTitle) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType(CirclePageType.circleClickSend), {
        "事件类型": "点击事件",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "行为对象": "按钮",
        "页面名称": pageTitle,
        "行为类型":"点击",
      });
    });
  }

  ///圈子详情发布
  static circleDetailsRevokeSend(String pageTitle) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType(CirclePageType.circleRevokeSend), {
        "事件类型": "点击事件",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "页面详情": "无",
        "行为对象": "按钮",
        "页面名称": pageTitle,
        "行为类型":"点击",
      });
    });
  }

  ///圈子详情发布
  static sendCircleResult(String pageTitle,bool result) {
    SpUtil.getData(amwayAccesstypeKey).then((customerType) {
      Zhugeio.track(_circlePageType(CirclePageType.circleRevokeSend), {
        "事件类型": "弹窗曝光事件",
        "事件详情":result?"发布成功":"发布失败",
        "页面类别": "创玩小站",
        "访客类别": customerType, //ABO
        "行为对象": "弹窗",
        "页面名称": pageTitle,
        "行为类型":"曝光",
      });
    });
  }




}
